package flc.ast.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.bean.StkTagResBean;

public class MovieListAdapter extends StkProviderMultiAdapter<StkTagResBean> {

    public MovieListAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new MovieListProvider());
    }

    private class MovieListProvider extends BaseItemProvider<StkTagResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_movie_list;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkTagResBean bean) {
            Glide.with(getContext()).load(bean.getUrl())
                    .into((ImageView) baseViewHolder.getView(R.id.ivMovieListItemImg));
            baseViewHolder.setText(R.id.tvMovieListItemName, bean.getName());
        }
    }

}
